package org.research.sdbx.datetime;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class DateFormat {

	private SimpleDateFormat format;
	
	public DateFormat(String pattern){
		this.format = new SimpleDateFormat(pattern);
	}
	
	public Calendar parse(String value){
		try {
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(format.parse(value));
			return calendar;
		} catch (ParseException e) {
			throw new RuntimeException(e);
		}
	}
	
	
	public static Calendar parse(String value, String pattern){
		try {
			SimpleDateFormat format = new SimpleDateFormat(pattern); 
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(format.parse(value));
			return calendar;
		} catch (ParseException e) {
			throw new RuntimeException(e);
		}
	}
	
	
	
	
}
